package com.example.demo.subscriber;
import com.example.demo.config.AmqpConfig;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@Configuration
public class FanoutSubscriber {

    @Autowired
    AmqpConfig amqpConfig;

    @Bean
    public Queue product1Queue() {
        return new Queue("product1.queue");
    }

    @Bean
    public Queue product2Queue() {
        return new Queue("product2.queue");
    }

    @Bean
    public Binding product1QueueBinding() {
        return BindingBuilder.bind(product1Queue()).to(amqpConfig.fanoutExchange());
    }

    @Bean
    public Binding product2QueueBinding() {
        return BindingBuilder.bind(product2Queue()).to(amqpConfig.fanoutExchange());
    }


}
